package com.lvchenglong.handler;

import com.lvchenglong.controller.CustomErrorType;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class MyControllerAdvice {

    @ExceptionHandler(value = Throwable.class)
    @ResponseBody
    public Map  handleControllerException(Throwable ex) {
        Map<String,String> map = new HashMap<>();
        map.put("error", "出错了404");
        return map;
    }

}
